package com.java.tutorials.jdk7.paths;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * Created by xuzhike on 2016/1/27.
 * http://www.java2s.com/Code/Java/JDK-7/GetfileContentType.htm
 */
public class GetfileContentType {
    public static void main(String[] args) throws Exception {
        displayContentType("/home/docs/users.txt");
        displayContentType("/home/docs/Chapter 2.doc");
        displayContentType("/home/docs/java.exe");
    }

    static void displayContentType(String pathText) throws Exception {
        Path path = Paths.get(pathText);
        String type = Files.probeContentType(path);
        System.out.println(type);
    }
}
